using System;
using System.Diagnostics;
using System.Windows;
using System.Windows.Media;
namespace Microsoft.Expression.Drawing.Core
{
	[DebuggerDisplay("({X}, {Y})")]
	internal struct Vector
	{
		public double X
		{
			get;
			set;
		}
		public double Y
		{
			get;
			set;
		}
		public double Length
		{
			get
			{
				return Math.Sqrt(this.X * this.X + this.Y * this.Y);
			}
		}
		public double LengthSquared
		{
			get
			{
				return this.X * this.X + this.Y * this.Y;
			}
		}
		public static bool operator ==(Vector vector1, Vector vector2)
		{
			return vector1.X == vector2.X && vector1.Y == vector2.Y;
		}
		public static bool operator !=(Vector vector1, Vector vector2)
		{
			return !(vector1 == vector2);
		}
		public static bool Equals(Vector vector1, Vector vector2)
		{
			return vector1.X.Equals(vector2.X) && vector1.Y.Equals(vector2.Y);
		}
		public override bool Equals(object obj)
		{
			if (obj != null && obj is Vector)
			{
				Vector vector = (Vector)obj;
				return Vector.Equals(this, vector);
			}
			return false;
		}
		public bool Equals(Vector value)
		{
			return Vector.Equals(this, value);
		}
		public override int GetHashCode()
		{
			return this.X.GetHashCode() ^ this.Y.GetHashCode();
		}
		public Vector(double x, double y)
		{
			this = default(Vector);
			this.X = x;
			this.Y = y;
		}
		public Vector(Point point)
		{
			this = default(Vector);
			this.X = point.get_X();
			this.Y = point.get_Y();
		}
		public void Normalize()
		{
			this /= Math.Max(Math.Abs(this.X), Math.Abs(this.Y));
			this /= this.Length;
		}
		public static double CrossProduct(Vector vector1, Vector vector2)
		{
			return vector1.X * vector2.Y - vector1.Y * vector2.X;
		}
		public static double AngleBetween(Vector vector1, Vector vector2)
		{
			double num = vector1.X * vector2.Y - vector2.X * vector1.Y;
			double num2 = vector1.X * vector2.X + vector1.Y * vector2.Y;
			return Math.Atan2(num, num2) * 57.295779513082323;
		}
		public static Vector operator -(Vector vector)
		{
			return new Vector(-vector.X, -vector.Y);
		}
		public void Negate()
		{
			this.X = -this.X;
			this.Y = -this.Y;
		}
		public Size ToSize()
		{
			return new Size(Math.Abs(this.X), Math.Abs(this.Y));
		}
		public Point ToPoint()
		{
			return new Point(this.X, this.Y);
		}
		public static Vector operator +(Vector vector1, Vector vector2)
		{
			return new Vector(vector1.X + vector2.X, vector1.Y + vector2.Y);
		}
		public static Vector Add(Vector vector1, Vector vector2)
		{
			return new Vector(vector1.X + vector2.X, vector1.Y + vector2.Y);
		}
		public static Vector operator -(Vector vector1, Vector vector2)
		{
			return new Vector(vector1.X - vector2.X, vector1.Y - vector2.Y);
		}
		public static Vector Subtract(Vector vector1, Vector vector2)
		{
			return new Vector(vector1.X - vector2.X, vector1.Y - vector2.Y);
		}
		public static Point operator +(Vector vector, Point point)
		{
			return new Point(point.get_X() + vector.X, point.get_Y() + vector.Y);
		}
		public static Point Add(Vector vector, Point point)
		{
			return new Point(point.get_X() + vector.X, point.get_Y() + vector.Y);
		}
		public static Vector operator *(Vector vector, double scalar)
		{
			return new Vector(vector.X * scalar, vector.Y * scalar);
		}
		public static Vector Multiply(Vector vector, double scalar)
		{
			return new Vector(vector.X * scalar, vector.Y * scalar);
		}
		public static Vector operator *(double scalar, Vector vector)
		{
			return new Vector(vector.X * scalar, vector.Y * scalar);
		}
		public static Vector Multiply(double scalar, Vector vector)
		{
			return new Vector(vector.X * scalar, vector.Y * scalar);
		}
		public static Vector operator /(Vector vector, double scalar)
		{
			return vector * (1.0 / scalar);
		}
		public static Vector Divide(Vector vector, double scalar)
		{
			return vector * (1.0 / scalar);
		}
		public static Vector operator *(Vector vector, Matrix matrix)
		{
			Point point = matrix.Transform(new Point(vector.X, vector.Y));
			point.set_X(point.get_X() - matrix.get_OffsetX());
			point.set_Y(point.get_Y() - matrix.get_OffsetY());
			return new Vector(point);
		}
		public static Vector Multiply(Vector vector, Matrix matrix)
		{
			Point point = matrix.Transform(new Point(vector.X, vector.Y));
			point.set_X(point.get_X() - matrix.get_OffsetX());
			point.set_Y(point.get_Y() - matrix.get_OffsetY());
			return new Vector(point);
		}
		public static double operator *(Vector vector1, Vector vector2)
		{
			return vector1.X * vector2.X + vector1.Y * vector2.Y;
		}
		public static double Multiply(Vector vector1, Vector vector2)
		{
			return vector1.X * vector2.X + vector1.Y * vector2.Y;
		}
		public static double Determinant(Vector vector1, Vector vector2)
		{
			return vector1.X * vector2.Y - vector1.Y * vector2.X;
		}
		public static explicit operator Size(Vector vector)
		{
			return vector.ToSize();
		}
		public static explicit operator Point(Vector vector)
		{
			return vector.ToPoint();
		}
		public static Point operator +(Point point, Vector vector)
		{
			return new Point(point.get_X() + vector.X, point.get_Y() + vector.Y);
		}
		public static Point operator -(Point point, Vector vector)
		{
			return new Point(point.get_X() - vector.X, point.get_Y() - vector.Y);
		}
	}
}
